package com.ailanyin.modules.flowable.service.impl;

import com.ailanyin.common.database.result.CommonPage;
import com.ailanyin.common.security.utils.SecurityUtil;
import com.ailanyin.modules.flowable.domain.WfForm;
import com.ailanyin.modules.flowable.domain.bo.WfFormBo;
import com.ailanyin.modules.flowable.domain.vo.WfFormVo;
import com.ailanyin.modules.flowable.mapper.WfFormMapper;
import com.ailanyin.modules.flowable.service.IWfFormService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author ailanyin
 * @version 1.0
 * @since 2022/12/13 0013 下午 16:28
 */
@Service
public class WfFormServiceImpl implements IWfFormService {

    @Resource
    private WfFormMapper wfFormMapper;

    @Override
    public WfFormVo queryById(Long formId) {
        return wfFormMapper.selectVoByFormId(formId);
    }

    @Override
    public int deleteByIds(List<Long> ids) {
        return wfFormMapper.deleteBatch(ids);
    }

    @Override
    public int updateForm(WfFormBo bo) {
        return wfFormMapper.updateByFormId(bo);
    }

    @Override
    public int insertForm(WfFormBo bo) {
        WfForm wfForm = new WfForm();
        wfForm.setFormName(bo.getFormName());
        wfForm.setContent(bo.getContent());
        wfForm.setRemark(bo.getRemark());
        wfForm.setCreateBy(SecurityUtil.getLoginUsername());
        wfForm.setCreateTime(new Date());
        return wfFormMapper.insert(wfForm);
    }

    @Override
    public List<WfFormVo> selectList(WfFormBo bo) {
        return wfFormMapper.selectList(bo);
    }
}
